home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1778 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: kbad.eglin.af.mil!rpi!not-for-mail
  2. From: thp@cs.ucr.edu (Tom Payne)
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: Re: Meaning of the specifier volatile?
  5. Date: 12 Jan 1996 19:10:22 -0000
  6. Organization: University of California, Riverside Department of Computer Science
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: vandevod@cs.rpi.edu
  9. Message-ID: <4d6bmu$bql@netlab.cs.rpi.edu>
  10. References: <4c9740$27n@netlab.cs.rpi.edu> <4cff74$gfj@netlab.cs.rpi.edu> <4cj5u4$qjm@netlab.cs.rpi.edu> <4cree9$9bv@netlab.cs.rpi.edu> <4d3hi9$qe2@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: 12 Jan 1996 18:33:13 GMT
  13.  
  14. J. Kanze (kanze@gabi-soft.fr) wrote:
  15. : X-Original-Date: 11 Jan 1996 12:45:44 +0100
  16. : Tom Payne (thp@cs.ucr.edu) wrote:
  17. : |> J. Kanze (kanze@gabi-soft.fr) wrote:
  18. : |> [stuff deleted]
  19. : |> : On point concerning volatile that I have not seen made is the fact that
  20. : |> : the C/C++ concept of volatile is orthogonal to atomicity of access.
  21. : |> : Declaring an object volatile is *NOT* sufficient with regards to
  22. : |> : asynchronous events; the object must still be of a type for which the
  23. : |> : compiler will generate atomic accesses.  
  24. : |> [stuff deleted]
  25. : |> Because of the signal-handlers-can't-read provision of the ANSI C
  26. : |> standard, atomicity is unnecessary in the coordination of asynchronous
  27. : |> activity for programs with defined behavior:
  28. : |>   *  signal handlers won't read any partially written non-atomic 
  29. : |>      shared variables, because they are not allowed to read variables 
  30. : |>      of static storage class in programs with defined behavior.
  31. : |>   *  the program itself won't read any partially written non-atomic 
  32. : |>      shared varible, because signal handlers don't return control 
  33. : |>      until they have completed their writes of volatile variables.
  34. [...]
  35. : Note that your statement, if allowed, could lead to anomalies if a
  36. : non-atomic read is interrupted, and the signal handler writes the
  37. : object.  The first part of the read sees the old value, and the second
  38. : part the new value.
  39.  
  40.  
  41. Oops -- I stand corrected!  The de facto atomicity of access by
  42. *uninterrupted* signal handlers doesn't cover all cases.
  43.  
  44. Tom Payne (thp@cs.ucr.edu)
  45.  
  46.  
  47.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  48.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  49.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  50.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  51.